<?php
/**
 * blXsltMail
 *
 * @version: 2.2
 * @date: 2008-12-04
 * @author: Vladimir Romanovich <ibnteo@gmail.com>
 * @license: GPL2
 */
class blXsltMail
{
    private $bl_xslt;

    public function __construct($bl_xslt)
    {
        $this->bl_xslt = $bl_xslt;
    }

    /**
     * отправить письмо
     */
    public function xbl_mail_send() {
        $this->bl_xslt->set_document_pi();

        $mail_node = $this->bl_xslt->element_pi_next;
        $to = $mail_node->getAttribute('to');
        $subject = $mail_node->getAttribute('subject');
        $body = $mail_node->getAttribute('body');

        $headers = 'From: '.$mail_node->getAttribute('from');
        $headers .= "\n".'X-Mailer: blXslt';
        $headers .= "\n".'Content-Type: text/plain; charset=utf-8';
        $headers .= "\n".'Content-Transfer-Encoding: 8bit';

        $result = mail($to, $subject, $body, $headers);

        $mail_node->setAttribute('result', $result ? 'true' : 'false');
    }

} // End blXsltMail
